-module(packet_tool).
-include("protocol.hrl").
-export([get_xl_cxt/2,get_cxt/2]).
get_xl_cxt([Cur|Other], F) ->
	A = F(Cur),
	if 
		A =:= true ->
			Cur;
		true ->
			get_xl_cxt(Other,F)
	end;
get_xl_cxt([],F) ->
	false.
	
get_cxt(l1,Cxts) ->
	get_xl_cxt(Cxts,fun(Cxt) ->
						if 
							is_record(Cxt,l1_protocol) ->
								true;
							true ->
%%								io:format("~p~n",[Cxt]),
								false
						end
					end);
get_cxt(ip,Cxts) ->
	get_xl_cxt(Cxts,fun(Cxt) ->
						if 
							is_record(Cxt,ip_protocol) ->
								true;
							true ->
%%								io:format("~p~n",[Cxt]),
								false
						end
					end).